package com.bi.autotest.pages;

import com.auto.base.PageAppium;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

/**
 * Created by yidian on 2018/4/23.
 */
public class CScanBPage extends PageAppium {

    public final String IMG_COMMONQRCODE_XP="//android.widget.Image[@content-desc='wx_help']/following-sibling::android.widget.Image[1]";
    public final String SETMONEY_XP="//android.widget.Button[@content-desc='设置金额']";
    public final String CHOOSE_QRCODE_XP="//android.widget.TextView[@text='识别图中二维码']";
    public final String KEYCODE_0_XP="//android.widget.Button[@content-desc='0']";
    public final String KEYCODE_1_XP="//android.widget.Button[@content-desc='1']";
    public final String KEYCODE_DOT_XP="//android.widget.Button[@content-desc='.']";
    public final String KEYCODE_2_XP="//android.widget.Button[@content-desc='2']";
    public final String KEYCODE_DEL_XP="//android.widget.Button[@index='5']";//键盘的回退键
    public final String CONFIRM_PAY_BUTTON_XP="//android.widget.Button[@content-desc='确认 支付']";
    public final String REMARK_ID="//*[@resource-id='input_msg']";
    public final String PAYTYPE_XP="//*[@resource-id='selectedPayType']";
    public final String PAYTYPE_XP2="//*[contains(@text(),"+ "会员卡" +")]";

    public final String VIPCARDPAY_BUTTON_XP="//android.widget.Button[@content-desc='会员卡付款']";


    public final String PAYSUCCESS_TEXT_XP="//android.view.View[@content-desc='付款成功']";
   // public final String COMPLETE_XP="//android.widget.Button[@content-desc='完 成']";
    public final String ARROW_DOWN_XP="//android.view.View[@resource-id='down']";
    public final String VIP_PAYTYPE_XP="//android.view.View[@content-desc='选择支付方式']/following-sibling::android.view.View[2]";
  //  public final String CANCEL_BUTTON_XP="//android.view.View[@content-desc='取消']";
    public final String RESULT_REMARK_XP="//*[contains(@text(),"+ "中国红" +")]";
   // public final String WXPAY_BUTTON_ID="button-card-submit";
    public final String PAY_RIGHTAWAY_XP="//android.widget.Button[@resource-id='com.tencent.mm:id/dyg']";
    public final String CLOSE_MSH_XP="//android.widget.Image[@content-desc='wx_close']";

    public final String SETMONEY_CONFIRM_XP="//android.widget.Button[@content-desc='确认 支付']";
    public final String SET_ADDGOODS_XP="//android.view.View[@content-desc='添加商品点这里']";
    public final String SET_INPUTMONEY_XP="//android.view.View[@content-desc='请输入有效金额']";
    public final String SETEFFECT_CONFIRMBUTTON_XP="//android.view.View[@content-desc='确定']";
    public final String SET_KEYCODEDEL_XP="//android.widget.Button[@content-desc='确认']/preceding-sibling::android.widget.Button";
    public final String CLEAR_MONEY_XP="//android.widget.Button[@resource-id='clearAmount']";

    //设置金额后的自助付款
    public final String SET_SUBMISSION_XP="//android.widget.Button[@resource-id='submissionSub']";
    //选择商品页面的元素
    public final String ADDXWZ_BUTTON_XP="//android.view.View[@content-desc='章鱼小丸子']/following-sibling::android.widget.Button";
    public final String CONFIRM_ADD_XP="//android.widget.Button[@content-desc='确认添加']";
    //左侧的关闭按钮
    public final String LEFT_CLOSE_ID="com.tencent.mm:id/hy";
    //故宫门店名
    public final String GG_STORE_XP="//android.view.View[@content-desc='故宫']";
    //qwer门店名
    public final String QWER_STORE_XP="//android.view.View[@content-desc='qwer']";
    public final String STORE_BUTTON_XP="//android.widget.Image[@content-desc='wx_help']/../preceding-sibling::android.view.View";
    //超市门店名
    public final String CS_STORE_XP="//android.view.View[@content-desc='超市']";
    //消费立减的文字
    public final String LIJIAN_TEXT_XP="//android.view.View[@content-desc='消费立减']";
    //0.01元的文字
    public final String SMALL_JINE_TEXT_XP="//android.view.View[@content-desc='¥0.01']";
    //折扣特权文字
    public final String ZHEKOU_TEXT_XP="//android.view.View[@content-desc='1折特权']";
    //申请开通的文字
    public final String APPLY_FLAVOR_XP ="//android.view.View[@content-desc='申请开通']";





    public CScanBPage(AndroidDriver androidDriver) {
        super(androidDriver);
    }

    public AndroidElement getCommonQRCodeImg(){
        return waitAutoByXp(IMG_COMMONQRCODE_XP);
    }

    public AndroidElement getChooseQRCode(){
        return waitAutoByXp(CHOOSE_QRCODE_XP);
    }

    public AndroidElement getPayTypeButton(){
        return waitAutoByXp(PAYTYPE_XP2);
    }

    public AndroidElement getConfirmPayButton(){
        return waitAutoByXp(CONFIRM_PAY_BUTTON_XP);
    }

    public AndroidElement getKeyCode_0(){
        return waitAutoByXp(KEYCODE_0_XP);
    }

    public AndroidElement getKeyCode_1(){
        return waitAutoByXp(KEYCODE_1_XP);
    }

    public AndroidElement getKeyCode_2(){
        return waitAutoByXp(KEYCODE_2_XP);
    }

    public AndroidElement getKeyCode_DOT(){
        return waitAutoByXp(KEYCODE_DOT_XP);
    }


    public boolean isExistVipCardPayButton(){
        return isXpathExist(VIPCARDPAY_BUTTON_XP);
    }

    public AndroidElement getKeyCode_Del(){
        return waitAutoByXp(KEYCODE_DEL_XP);
    }

    public boolean isExistPaySuccessText(){
        return isXpathExist(PAYSUCCESS_TEXT_XP);
    }

    public AndroidElement getDownButton(){
        return waitAutoByXp(ARROW_DOWN_XP);
    }

    public AndroidElement getRemarkInputArea(){
        return waitAutoByXp(REMARK_ID);
    }

    public boolean isExistResultRemarkText(){
        return isXpathExist(RESULT_REMARK_XP);
    }

    public boolean isExistPayRightAwayButton(){
        return isXpathExist(PAY_RIGHTAWAY_XP);
    }

    public AndroidElement getMSHCloseButton(){
        return waitAutoByXp(CLOSE_MSH_XP);
    }

    //设置金额
    public AndroidElement getSetMoneyButton(){
        return waitAutoByXp(SETMONEY_XP);
    }

    public boolean isExistSetMoneyText(){
        return isXpathExist(SETMONEY_XP);
    }

    public AndroidElement getSetConfirmButton(){
        return waitAutoByXp(SETMONEY_CONFIRM_XP);
    }

    public AndroidElement getAddGoodsButton(){
            return waitAutoByXp(SET_ADDGOODS_XP);
    }

    public boolean isExistInputMoneyText(){
        return isXpathExist(SET_INPUTMONEY_XP);
    }

    public AndroidElement getSetEffectConfirmButton(){
        return waitAutoByXp(SETEFFECT_CONFIRMBUTTON_XP);
    }

    //获取设置金额键盘上的删除键
    public AndroidElement getSetDelButton(){
        return waitAutoByXp(SET_KEYCODEDEL_XP);
    }

    public boolean isExistClearText() {
        return isXpathExist(CLEAR_MONEY_XP);
    }

    public AndroidElement getSetClearButton(){
        return waitAutoByXp(CLEAR_MONEY_XP);
    }

    public AndroidElement getSetSubmissionButton(){
        return waitAutoByXp(SET_SUBMISSION_XP);
    }

    public AndroidElement getElementByName(String name){
        return waitAutoByName(name);
    }

    public boolean isExistElementByName(String name){
        return isNameElementExist(name);
    }

    public AndroidElement getAddXWZButton(){
        return waitAutoByXp(ADDXWZ_BUTTON_XP);
    }

    public AndroidElement getConfirmAddButton(){
        return waitAutoByXp(CONFIRM_ADD_XP);
    }

    public AndroidElement getLeftCloseButton(){
        return waitAutoById(LEFT_CLOSE_ID);
    }

    public AndroidElement getStoreButton(){
        return waitAutoByXp(STORE_BUTTON_XP);
    }

    public AndroidElement getQWERButton(){
        return waitAutoByXp(QWER_STORE_XP);
    }

    public AndroidElement getGGButton(){
        return waitAutoByXp(GG_STORE_XP);
    }

    public AndroidElement getCSButton(){
        return waitAutoByXp(CS_STORE_XP);
    }
    public boolean isExistLiJianText(){
        return isXpathExist(LIJIAN_TEXT_XP);
    }

    public boolean isExistSmallJineText() {
        return isXpathExist(SMALL_JINE_TEXT_XP);
    }

    public boolean isExistZheKouText() {
        return isXpathExist(ZHEKOU_TEXT_XP);
    }

    public boolean isExistUnOpenText() {
        return isXpathExist(APPLY_FLAVOR_XP);
    }

}
